<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

include_once 'base_controller.php';

class Site extends Base_Controller 
{
    public function __construct() 
    {
        parent::__construct();
        $this->load->model('userlist_model');
    }

    public function index()
    {
        $this->load->view('index');
        $this->load->view('footer');
    }
	
    public function login()
    {
        if($this->userlist_model->checkLogin())
            redirect('site/index');
        else
        {
            if( ! empty($_POST))
            {
                if($this->userlist_model->login($_POST['base']))
                    redirect('site/index');
                else
                    echo '用户名或密码错误';
                exit;
            }
            $this->load->view('login');
        }
    }
    
    public function logout()
    {
        $this->userlist_model->logout();
        redirect('site/login');
    }
}